package com.cloudlead.common.lang.persistence;

import java.io.Serializable;

import javax.validation.constraints.NotNull;

import com.cloudlead.common.lang.annotation.Label;

@Label("查询条件项")
public class Term implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -464760821506810447L;
    @NotNull
    @Label("属性")
    private String property;
    @Label("值")
    private Object value;
    @NotNull
    @Label("操作符")
    private Operator operator;

    public Term() {
    }

    public Term(String property, Object value) {
        this.property = property;
        this.value = value;
        this.operator = Operator.EQ;
    }

    public Term(String property, Operator operator, Object value) {
        this.property = property;
        this.value = value;
        this.operator = operator;
    }

    public String getProperty() {
        return property;
    }

    public void setProperty(String property) {
        this.property = property;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public Operator getOperator() {
        return operator;
    }

    public void setOperator(Operator operator) {
        this.operator = operator;
    }

    @Override
    public String toString() {
        return String.format("{%s %s %s}", property, operator, value);
    }

}